<template>
    <el-form :model="editForm"  label-width="120px" :rules="editFormRules" ref="editFormRef">
        <el-form-item label="主键" prop="id">
            <el-input  v-model="editForm.id" placeholder="主键" :maxlength="50" @change="editSomeFields(editForm,'id',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="评论人" prop="userid">
            <el-input  v-model="editForm.userid" placeholder="评论人" :maxlength="50" @change="editSomeFields(editForm,'userid',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="评论人姓名" prop="username">
            <el-input  v-model="editForm.username" placeholder="评论人姓名" :maxlength="50" @change="editSomeFields(editForm,'username',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="星级" prop="star">
            <el-input  v-model="editForm.star" placeholder="星级" :maxlength="1" @change="editSomeFields(editForm,'star',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="时间" prop="cdate">
            <el-date-picker type="date" placeholder="选择日期"  v-model="editForm.cdate"  value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD" @change="editSomeFields(editForm,'cdate',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="主体业务编号" prop="bizId">
            <el-input  v-model="editForm.bizId" placeholder="主体业务编号" :maxlength="50" @change="editSomeFields(editForm,'bizId',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="上级评论" prop="pid">
            <el-input  v-model="editForm.pid" placeholder="上级评论" :maxlength="50" @change="editSomeFields(editForm,'pid',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="点赞数量" prop="ups">
            <el-input  v-model="editForm.ups" placeholder="点赞数量" :maxlength="10" @change="editSomeFields(editForm,'ups',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="是否显示" prop="isShow">
            <el-input  v-model="editForm.isShow" placeholder="是否显示" :maxlength="1" @change="editSomeFields(editForm,'isShow',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="回复用户编号" prop="toUserid">
            <el-input  v-model="editForm.toUserid" placeholder="回复用户编号" :maxlength="50" @change="editSomeFields(editForm,'toUserid',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="回复用户名" prop="toUsername">
            <el-input  v-model="editForm.toUsername" placeholder="回复用户名" :maxlength="50" @change="editSomeFields(editForm,'toUsername',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="层级" prop="lvl">
            <el-input  v-model="editForm.lvl" placeholder="层级" :maxlength="1" @change="editSomeFields(editForm,'lvl',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="评论内容" prop="context">
            <el-input  v-model="editForm.context" placeholder="评论内容" :maxlength="1000" @change="editSomeFields(editForm,'context',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="机构编号" prop="branchId">
            <el-input  v-model="editForm.branchId" placeholder="机构编号" :maxlength="50" @change="editSomeFields(editForm,'branchId',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="地址" prop="ip">
            <el-input  v-model="editForm.ip" placeholder="地址" :maxlength="50" @change="editSomeFields(editForm,'ip',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="城市编号" prop="cityId">
            <el-input  v-model="editForm.cityId" placeholder="城市编号" :maxlength="50" @change="editSomeFields(editForm,'cityId',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="城市名称" prop="cityName">
            <el-input  v-model="editForm.cityName" placeholder="城市名称" :maxlength="50" @change="editSomeFields(editForm,'cityName',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="状态" prop="status">
            <el-input  v-model="editForm.status" placeholder="状态" :maxlength="1" @change="editSomeFields(editForm,'status',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="儿子节点数量" prop="childNums">
            <el-input-number  v-model="editForm.childNums" :min="0" :max="200" :precision="0" @change="editSomeFields(editForm,'childNums',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="上级业务编号" prop="pbizId">
            <el-input  v-model="editForm.pbizId" placeholder="上级业务编号" :maxlength="50" @change="editSomeFields(editForm,'pbizId',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="评论对象类型" prop="objType">
            <el-input  v-model="editForm.objType" placeholder="评论对象类型" :maxlength="10" @change="editSomeFields(editForm,'objType',$event)" :disabled="disField"/>
        </el-form-item>
        <el-form-item label="通知谁看" prop="notifyUserids">
            <el-input  v-model="editForm.notifyUserids" placeholder="通知谁看" :maxlength="255" @change="editSomeFields(editForm,'notifyUserids',$event)" :disabled="disField"/>
        </el-form-item>
    </el-form>
    <div class="footer">
        <el-button @click="close" icon="close">关闭</el-button>
        <el-button icon="success-filled" v-if="currOpType=='add'|| (currOpType=='edit' && someOpen==false)" v-loading="load.edit" type="primary" @click="saveSubmit" :disabled="disBtn('addBtn') || !checkBtnQx('addBtn',menuDefId) || load.edit">提交</el-button>
    </div>
</template>

<script>
import * as XmCommentApi from '@/api/xm/core/xmComment';
import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin.js';
import { mapState } from 'pinia'
import { useUserStore } from '@/store/modules/user'

export default {
    name:'XmCommentForm',
    mixins:[MdpFormMixin],
    computed: {
        ...mapState(useUserStore,['userInfo'])
    },
    props:{
       // 是否开启editSomeField模式
       someOpen:{
          type: Boolean,
          default: true,
      },
    },
    data() {
        return {
            menuDefId:'',//menu_def.id 菜单表菜单编号，用于按钮权限判断
            pkNames:["id"],//表格主键的java属性名称，驼峰命名，默认为id,支持多主键
            currOpType:'add',//表单 add、edit，所有按钮可动、detail-只看不能操作
            editFormRules: {
                id:[
                //{ required: true, message: '此项必填', trigger: 'change' },
                //{ min: 1,max: 200, message: '长度在1到200之间', trigger: 'change'}
                ]
            },
            editForm: {
                id:'',userid:'',username:'',star:'',cdate:'',bizId:'',pid:'',ups:'',isShow:'',toUserid:'',toUsername:'',lvl:'',context:'',branchId:'',ip:'',cityId:'',cityName:'',status:'',childNums:'',pbizId:'',objType:'',notifyUserids:''
            },
            //增删改查(含批量)接口
            apis:{
                queryById: XmCommentApi.queryXmCommentById,
                add: XmCommentApi.addXmComment,
                edit: XmCommentApi.editXmComment,
                editSomeFields: XmCommentApi.editSomeFieldsXmComment
            },
        }
    },
    methods: {
         //由组件扩展添加其它的初始页面的逻辑(mounted+onOpen都会调用此函数，建议只添加公共逻辑)
         initCurrData(){

         },
        /**
         * 检查参数是否满足调用后台接口的条件
         * @returns true / false
         */
        preParamCheck(params){
            return true;
        },
        /**
         * 对修改的字段进行判断，返回false ,将取消更新数据库,由组件扩展
         * @param {*} row 当前选中的行
         * @param {*} fieldName 修改的字段名
         * @param {*} $event 修改后的值
         * @param {*} params 将要提交服务器的参数
         * @returns true/false 返回false ,将取消更新数据库
         */
        editSomeFieldsCheck(row,fieldName,$event,params){
            params[fieldName]=$event
            return true;
        },
    },
    mounted() {

    }
}

</script>

<style scoped>

</style>